from tkinter import *
import webbrowser

root = Tk()

text = Text(root,width=30,height=5)
text.pack()

text.insert(INSERT,'I love FishC.com!')

#text.tag_add('tag1','1.7','1.12','1.14')#添加标签位置
#text.tag_config('tag1',background='yellow',foreground='red')#设置标签样式
text.tag_add('link','1.7','1.16')
text.tag_config('link',foreground='blue',underline=True)

def show_arrow(event):
    text.config(cursor='arrow')

def show_xterm(event):
    text.config(cursor='xterm')

def click(event):
    webbrowser.open('http://www.fishc.com')

text.tag_bind('link','<Enter>',show_arrow)
text.tag_bind('link','<Leave>',show_xterm)
text.tag_bind('link','<Button-1>',click)

mainloop()
